package cn.edu.sicau.databasepp.entity;

import javax.persistence.*;
import java.util.Objects;

@Entity
@Table(name = "user", schema = "sqlexcise", catalog = "")
public class UserEntity
{
    private long userId;
    private String password;
    private String userName;
    private String realname;
    private String telNumber;
    private String email;

    @Id
    @Column(name = "user_id", nullable = false)
    public long getUserId()
    {
        return userId;
    }

    public void setUserId(long userId)
    {
        this.userId = userId;
    }

    @Basic
    @Column(name = "password", nullable = true, length = 32)
    public String getPassword()
    {
        return password;
    }

    public void setPassword(String password)
    {
        this.password = password;
    }

    @Basic
    @Column(name = "user_name", nullable = true, length = 32)
    public String getUserName()
    {
        return userName;
    }

    public void setUserName(String userName)
    {
        this.userName = userName;
    }

    @Basic
    @Column(name = "realname", nullable = true, length = 32)
    public String getRealname()
    {
        return realname;
    }

    public void setRealname(String realname)
    {
        this.realname = realname;
    }

    @Basic
    @Column(name = "tel_number", nullable = true, length = 16)
    public String getTelNumber()
    {
        return telNumber;
    }

    public void setTelNumber(String telNumber)
    {
        this.telNumber = telNumber;
    }

    @Basic
    @Column(name = "email", nullable = true, length = 64)
    public String getEmail()
    {
        return email;
    }

    public void setEmail(String email)
    {
        this.email = email;
    }

    @Override
    public boolean equals(Object o)
    {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        UserEntity that = (UserEntity) o;
        return userId == that.userId &&
                Objects.equals(password, that.password) &&
                Objects.equals(userName, that.userName) &&
                Objects.equals(realname, that.realname) &&
                Objects.equals(telNumber, that.telNumber) &&
                Objects.equals(email, that.email);
    }

    @Override
    public int hashCode()
    {
        return Objects.hash(userId, password, userName, realname, telNumber, email);
    }
}
